var t = getApp(), a = void 0;

Page({
    data: {
        showFee: "0.00",
        realFee: 0,
        cashFee: null,
        type: 1,
        typeFilter: "user"
    },
    cashInput: function(t) {
        this.setData({
            cashFee: t.detail.value
        });
    },
    onLoad: function(t) {
        a = this;
        var e = "";
        e = 1 == t.type ? "user" : 2 == t.type ? "run" : "agent", a.setData({
            type: t.type,
            typeFilter: e
        }), this.getData();
    },
    getData: function() {
        var e = "amountUser";
        1 == this.data.type ? e = "amountUser" : 2 == this.data.type ? e = "amountRun" : 3 == this.data.type && (e = "amountAgent"), 
        wx.showLoading({
            title: "加载中",
            mask: !0
        }), t.com.post("wx/cash/" + e, {}, function(t) {
            wx.hideLoading(), 0 === t.errno && a.setData({
                showFee: t.data.surplus_amount.toFixed(2),
                realFee: t.data.surplus_amount,
                cashConfig: t.data.cashConfig
            });
        });
    },
    cashAll: function() {
        this.data.realFee > this.data.cashConfig[this.data.typeFilter + "_min_cash"] ? this.setData({
            cashFee: this.data.realFee.toFixed(2)
        }) : wx.showToast({
            title: "单笔提现金额不能小于" + this.data.cashConfig[this.data.typeFilter + "_min_cash"] + "元",
            icon: "none"
        });
    },
    cashIt: function() {
        parseFloat(this.data.cashFee) <= parseFloat(this.data.cashConfig[this.data.typeFilter + "_min_cash"]) ? wx.showToast({
            title: "单笔提现金额不能小于" + this.data.cashConfig[this.data.typeFilter + "_min_cash"] + "元",
            icon: "none"
        }) : parseFloat(this.data.cashFee) > parseFloat(this.data.cashConfig[this.data.typeFilter + "_max_cash"]) ? wx.showToast({
            title: "单笔提现金额不能大于" + this.data.cashConfig[this.data.typeFilter + "_max_cash"] + "元",
            icon: "none"
        }) : this.data.cashFee > this.data.realFee + .01 ? (wx.showToast({
            title: "提现金额不能大于余额",
            icon: "none"
        }), this.setData({
            cashFee: this.data.realFee.toFixed(2)
        })) : this.data.bankCard ? (wx.showLoading({
            title: "请求中",
            task: !0
        }), t.com.post("wx/cash/" + this.data.typeFilter, {
            cashFee: this.data.cashFee,
            account_id: this.data.bankCard.id
        }, function(t) {
            0 === t.errno && (wx.hideLoading(), wx.showToast({
                title: t.errmsg,
                duration: 1e3,
                mask: !0
            }), setTimeout(function() {
                wx.redirectTo({
                    url: "/pages/runman/cash/recode/recode?type=" + this.data.type
                });
            }, 1e3));
        })) : wx.showToast({
            title: "请选择一张银行卡",
            icon: "none"
        });
    }
});